<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>

  export default {
    name: 'App',
    created() {
      //localStorage是永久存储在本地，除非你主动去删除
      //sessionStorage是存储到当前页面关闭为止

      //页面加载读取sessionStorage信息
      if (sessionStorage.getItem("store")){
        this.$store.replaceState(Object.assign({},this.$store.state,JSON.parse(sessionStorage.getItem("store"))))
      }

      //刷新页面把vuex信息存储到sessionStorage
      window.addEventListener("beforeunload",() => {
        sessionStorage.setItem("store",JSON.stringify(this.$store.state))
      })
    }
  }
</script>

<style scoped>

</style>
